package com.example.relativelayoutevent;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.RelativeLayout;

public class MyLayout extends RelativeLayout {
    public MyLayout(Context context) {
        super(context);
    }

    public MyLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        boolean onTouchEventResult = super.onTouchEvent(event);

        Log.i("eventTest", "MyLayoutonTouchEvent:action--"+event.getAction()+
                ",result="+onTouchEventResult+",view:MyLayout");
        return  onTouchEventResult;//默認返回false,因为设置了onClickListener,MyLayout变为clickable = true,所以返回true;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
       boolean dispatchResult =  super.dispatchTouchEvent(event);   //默认返回true
        Log.i("eventTest", "MyLayoutdispatchTouch:action--"+event.getAction()+
                ",result="+dispatchResult+",view:MyLayout");
       return dispatchResult;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        boolean onInterceptResult = super.onInterceptTouchEvent(event);  //默认返回false

        onInterceptResult = true;
        Log.i("eventTest", "MyInterceptTouch:action--"+event.getAction()+
                ",result="+onInterceptResult+",view:MyLayout");


        return onInterceptResult;

    }
}
